Skip to content

Add template list, template view, and --template on issue and project create - #283

Open
schpetbot wants to merge 1 commit into
schpet/project-collection-flagsfrom
schpet/templates
Open

Add template list, template view, and --template on issue and project create#283
schpetbot wants to merge 1 commit into
schpet/project-collection-flagsfrom
schpet/templates

Conversation

@schpetbot

Copy link
Copy Markdown
Collaborator

Second of a two-PR stack, based on #282. Merge that first; this PR's diff collapses to one commit once it lands.

Templates become a first-class surface, patterned on Linear's MCP list_templates / get_template / template tools: a template list command (--type issue|project|document, --team <key|name|id> which returns that team's templates plus workspace ones, --json), template view <name|id> showing what the template pre-fills, and --template <name|id> on issue create and project create that applies the template server-side.

Semantics confirmed live: an explicit --description replaces the template body and omitting it keeps the body; --label merges with the template's labels; explicit flags override template values; the title becomes optional with a template. Linear rejects useDefaultTemplate together with templateId for both issues and projects, so --template takes the place of the team's default template and --no-use-default-template alongside it is a no-op. templateData is a JSON-encoded string whose issue body is ProseMirror JSON, so a small ProseMirror-to-Markdown renderer backs template view. Document templates are list and view only because DocumentCreateInput has no template field.

template list --json returns a bare array because Query.templates is an unpaginated list in the API, not a connection.

Verified: 777 tests in both color modes, a 17-case QA table with 15 cases live (the workspace had no templates, so scratch ones were created via templateCreate and deleted, along with the scratch issues and project they produced), and four high-effort Codex review passes whose real findings (Markdown re-interpretation in bodies, nested sub-issue rendering, order-dependent scope diagnostics, code-unit truncation, workspace-first ordering, list-marker escaping, fence sizing) are all fixed. The final pass was clean.

https://claude.ai/code/session_01A9qEGri4p2HZMQSuYsBmub

… create

Linear templates were invisible from the CLI: `issue create` could only
apply the team's default template, and there was no way to see which
templates exist, what one pre-fills, or to pick one for a project. The
MCP server exposes list_templates, get_template, and a template
parameter on save_issue/save_project; this mirrors that surface.

`template list` fetches the workspace-wide `templates` list and filters
client-side by `--type` (issue, project, document) and `--team` (that
team's templates plus workspace-level ones, resolved through the shared
team lookup). `template view <name|id>` prints the metadata and every
key of `templateData`, rendering the ProseMirror body Linear stores
under `descriptionData` as markdown. `--json` on both returns the raw
GraphQL objects with `templateData` still a JSON-encoded string.

`--template <name|id>` on `issue create` and `project create` resolves
the reference against the target type and team(s) and sends
`templateId`, so Linear applies the template server-side. Semantics
confirmed against the live API and stated in the help text: explicit
flags override the template's values, `--label` merges with the
template's labels, `--description` replaces the template body (omitting
it keeps the body), and `issue create --template` makes `--title`
optional. Linear rejects `useDefaultTemplate` together with
`templateId`, despite the schema saying `templateId` wins for projects,
so `--template` drops the default-template flag; `--no-use-default-
template` may still be passed alongside it. A wrong-type or other-team
template errors before any mutation; a name shared by several eligible
templates errors with their IDs; `template(id:)` is non-null, so a
missing UUID is translated from Linear's "No template found" error into
the usual not-found error.

`DocumentCreateInput` has no `templateId`, so document templates can be
listed and viewed but not applied; `document create` is unchanged.

Claude-Session: https://claude.ai/code/session_01A9qEGri4p2HZMQSuYsBmub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants